package ge.telasi.tasks.ui.user;

import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

/**
 * @author dimitri
 */
public class GroupView extends javax.swing.JInternalFrame {

    public GroupView() {
        initComponents();
        groupList.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                groupUserTable1.setGroup(groupList.getSelectedGroup());
                groupUserTable1.refresh();
            }
        });
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jSplitPane1 = new javax.swing.JSplitPane();
        jPanel1 = new javax.swing.JPanel();
        jToolBar1 = new javax.swing.JToolBar();
        btnGroupRefresh = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        groupList = new ge.telasi.tasks.ui.user.GroupList();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        groupUserTable1 = new ge.telasi.tasks.ui.user.GroupUserTable();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("მომხმარებელთა ჯგუფების სია");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/ge/telasi/resorces/icons16x16/group.png"))); // NOI18N

        jSplitPane1.setDividerLocation(200);

        jPanel1.setLayout(new java.awt.BorderLayout());

        jToolBar1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jToolBar1.setFloatable(false);
        jToolBar1.setOrientation(1);
        jToolBar1.setRollover(true);

        btnGroupRefresh.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ge/telasi/resorces/icons16x16/arrow_refresh_small.png"))); // NOI18N
        btnGroupRefresh.setFocusable(false);
        btnGroupRefresh.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnGroupRefresh.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnGroupRefresh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGroupRefreshActionPerformed(evt);
            }
        });
        jToolBar1.add(btnGroupRefresh);

        jPanel1.add(jToolBar1, java.awt.BorderLayout.WEST);

        jScrollPane1.setViewportView(groupList);

        jPanel1.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jSplitPane1.setLeftComponent(jPanel1);

        jPanel2.setLayout(new java.awt.BorderLayout());

        groupUserTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jScrollPane2.setViewportView(groupUserTable1);

        jPanel2.add(jScrollPane2, java.awt.BorderLayout.CENTER);

        jSplitPane1.setRightComponent(jPanel2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 527, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnGroupRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGroupRefreshActionPerformed
        refresh();
}//GEN-LAST:event_btnGroupRefreshActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnGroupRefresh;
    private ge.telasi.tasks.ui.user.GroupList groupList;
    private ge.telasi.tasks.ui.user.GroupUserTable groupUserTable1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration//GEN-END:variables

    public boolean refresh() {
        return groupList.refresh();
    }

}
